<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function showDiv(divId){
            //根据ID得到对象
            var showObj=document.getElementById(divId);
            if (showObj.style.display == "block"){
                showObj.style.display="none";
            }else{
                showObj.style.display="block"
            }
        }
    </script>

</head>
<style>
    .head{
        font-size: 30px;
        text-align: center;
        border: 1px solid black;
        background-color: red;
    }
    .body{
        font-size: 22px;
        text-align: center;
        border: 1px solid black;
        line-height: 50px;
        background-color: yellow;
        display: none;
    }
</style>

<body>
<div id="mainDiv">
    <div class="head" onclick="showDiv('friend')">好友</div>
    <div class="body" id="friend">
        韦小宝<br>
        陈近南<br>
        风冀中
    </div>
    <div class="head" onclick="showDiv('parent')">
        亲人
    </div>
    <div class="body" id="parent">
        段誉<br>
        虚竹<br>
        乔峰
    </div>
    <div class="head" onclick="showDiv('black')">
        黑名单
    </div>
    <div class="body" id="black">
        海大富<br>
        岳不群<br>
        东方不败
    </div>
</div>
</body>
</html>